from urllib import parse, request

code = "杀鸡"
code = parse.quote(code)  # 转为ASCII码
print(code)
print(parse.unquote(code))
url = "http://httpbin.org/get?name={}".format(code)
res = request.urlopen(url)
print("状态码", res.getcode())

params = {"name": "回答", "name2": "1234", "name3": 1451}
# 字典转换为url请求参数的形式
params_asc = parse.urlencode(params)
print(params_asc)
# 把请求参数转换成Unicode
params_str = parse.parse_qs(params_asc)
print("utf-8", params_str)
